﻿@model IEnumerable<Beeldbankmvc.Models.BEELDBANK_GEBIED>
@using Beeldbankmvc.Code
@using System.Configuration

@{
	ViewBag.Title = "GenerateSQLViewCode";
}



@foreach (var item in Model) {

	
<p>
/****** Object:  View [dbo].[@Html.Raw("BEELDBANK_GEBIED_" + item.Id)] ******/ <br/>
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[@Html.Raw("BEELDBANK_GEBIED_" + item.Id)]')) <br/>
DROP VIEW [dbo].[@Html.Raw("BEELDBANK_GEBIED_" + item.Id)] <br/>
GO <br/>

/****** Object:  View [dbo].[@Html.Raw("BEELDBANK_GEBIED_" + item.Id)] ******/ <br/>
SET ANSI_NULLS ON <br/>
GO <br/>

SET QUOTED_IDENTIFIER ON <br/>
GO <br/>

CREATE VIEW [dbo].[@Html.Raw("BEELDBANK_GEBIED_" + item.Id)] <br/>
AS <br/>
SELECT     Id, Titel, StatusId, Datum_Realisatie, Latitude, Longitude <br/>
FROM         dbo.BEELDBANK_MEDIAOBJECT <br/>
WHERE     (Latitude <= @Convert.ToString(item.linksBovenLatitude).Replace(',','.') AND Latitude >= @Convert.ToString(item.rechtsOnderLatitude).Replace(',', '.') AND Longitude >= @Convert.ToString(item.linksBovenLongitude).Replace(',', '.') AND Longitude <= @Convert.ToString(item.rechtsOnderLongitude).Replace(',', '.')) <br/>
AND (StatusId = @Convert.ToUInt32(ConfigurationManager.AppSettings["publishedExternal"])) <br />
GO <br/>
</p>
}



